set more off

use dataset, clear

*** covariates ***

local X1 totalrevownsourcespcp pcttotaltax pcttotalig
local X2 lpopulation popdensity incomepcp pctba pct65plus 
local X3 crimepcp totalpolicepcp dem ngovspcp netmigration H pcthisp herf pctforeign

local X `X1' `X2' `X3'
 
replace pctblackgov = log(pctblackgov + 1)

*** rescale ***

foreach x in `X' pctblack pctblackgov {
	su `x'
	replace `x' = (`x' - r(min)) / (r(max) - r(min))
	drop if mi(`x')
}

*** interactions ***

gen pctblackXanyblackgov = pctblack*anyblackgov

label variable pctblack "Percent black population"
label variable pctblackgov "Percent black council"
label variable anyblackgov "Any black council"
label variable pctblackXanyblackgov "Black pop X any black council"

*** regressions ***

eststo clear

eststo: reg lfinesandforfeitspcp pctblack anyblackgov, robust
eststo: reg lfinesandforfeitspcp pctblack anyblackgov `X', robust
estadd local Controls = "\checkmark"
eststo: reg lfinesandforfeitspcp pctblack anyblackgov pctblackXanyblackgov, robust
eststo: reg lfinesandforfeitspcp pctblack anyblackgov pctblackXanyblackgov `X', robust
estadd local Controls = "\checkmark"

#delimit;

esttab 
	using "table2.tex"
	,
		replace 
		label
		star(* .05 ** .01 *** .001)
		keep(pctblack* pctblack anyblackgov)
		gap
		booktabs
		cells(b(fmt(2) star) se(par))
		collabels(none)
		nomtitles
		order(pctblack anyblackgov pctblackXanyblackgov)
		stats(Controls)
		width(\textwidth)		
		;
#delimit cr

esttab, keep(pctblack* pctblack anyblackgov) stats(mydiff1 mydiff0 mydiff) se compress star(+ .1 * .05 ** .01 *** .001)
